<?php
/**
 * Handles uncaught exceptions
 */
class ExceptionHandler {
	/**
	 * Handles uncaught $exception
	 *
	 * @param Exception $exception
	 */
	public static function handleException (Exception $exception) {
		echo '<body style="background: #eee"><div style="background: #fdfdfd url(http://exscale.se/__files/uploads/dryicons.com-shine-icon-set-warning.png) no-repeat 20px 30px; margin: 60px auto; padding: 30px 20px 30px 180px; width: 40%; border: 1px solid #E5E5E5; font: 120%/1.4 Helvetica, Arial, sans-serif; color: #333; box-shadow: 1px 2px 3px rgba(0, 0, 0, .4); border-radius: 0;">';
		echo '<h2 style="margin: 0 0 10px; color: red">SleekPHP Error</h2>';
		echo "<p style=\"margin: 0 0 10px;\">{$exception->getMessage()}</p>";
		echo "<p style=\"margin: 0 0 10px;;\"><small><strong>On line:</strong> {$exception->getLine()}<br/><strong>In file:</strong> {$exception->getFile()}</small></p>";

		if (isset($_GET['backtrace'])) {
			echo '<pre style="background: #fafafa; font: 100%/1.2 monospace; max-height: 400px; overflow: auto; margin: 30px 0 0 -150px; padding: 30px; border: 1px solid #ddd;">';
			var_dump(debug_backtrace());
			echo '</pre>';
		}
		else {
			echo '<p style="margin: 0;"><small>Set <a href="?backtrace">?backtrace</a> for backtrace.</small></p>';
		}

		echo '</div></body>';
	}
}
